﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MS.InformationManagement.Presenter.Support;
using MS.InformationManagement.DAL.RecordCenter;
using MS.InformationManagement.Core.RecordSiteQuery;
using MS.InformationManagement.Support.Constants;
using MS.InformationManagement.BLL.GestionDeUsuarios;

namespace MS.InformationManagement.Presenter.DepartmentSelector
{
    public class DepartmentSelectorPresenter : BasePresenter<IDepartmentSelectorView>
    {

        #region Constructors

        public DepartmentSelectorPresenter(IDepartmentSelectorView view) : base(view) { }

        #endregion

        #region Public Methods

        public void HandleLoad()
        {
            var gestionUsers = new GestionDeUsuariosBLL();
            if (View.ShowOnlyAllowedDependencies)
                View.Departments = View.InitialDepartmentValue.HasValue ? gestionUsers.GetAllowedSeccionsCurrentUser(View.InitialDepartmentValue.Value) : gestionUsers.GetAllowedSeccionsCurrentUser();
            else
                View.Departments = QueryRecordsSiteHelper<Seccion>.QueryAllRecords(GlobalConstants.LIST_BIBLIOTECA_SECCION, new Nullable<uint>());
            View.Show();
        }

        #endregion

    }
}
